﻿using System;
using System.Text;

namespace CID.Support.BinaryContentConverters
{
    /// <summary>
    /// An <see cref="IBinaryContentConverter"/> implementation that translates the binary content into unicode strings
    /// </summary>
    public class UnicodeBinaryContentConverter : IBinaryContentConverter
    {
        public string ToString(byte[] content)
        {
            return (content != null) ? Encoding.Unicode.GetString(content) : String.Empty;
        }

        public byte[] ToBinaryContent(string contentStringRepresentation)
        {
            return (contentStringRepresentation != null) ? Encoding.Unicode.GetBytes(contentStringRepresentation) : new byte[0];
        }
    }
}
